home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / amigae.jan.archive / 000017_crash!iucf.indiana.edu!EJAMES_Thu, 6 Jan 94 02:13:20 PST.msg < prev    next >
Text File  |  1994-02-17  |  2KB  |  40 lines

  1. Received: by bkhouse.cts.com (V1.16/Amiga)
  2.     id AA00000; Thu, 6 Jan 94 02:13:20 PST
  3. Received: from venus.iucf.indiana.edu by crash.cts.com with smtp
  4.     (Smail3.1.28.1 #18) id m0pHfZ9-0001HzC; Wed, 5 Jan 94 13:14 PST
  5. Message-Id: <m0pHfZ9-0001HzC@crash.cts.com>
  6. Date: 5 Jan 94 10:02:00 EST
  7. From: EJAMES@iucf.indiana.edu
  8. To: "amigae" <amigae@bkhouse.cts.com>
  9. Subject: getchar() without the line feed
  10.  
  11.   There have been a few questions on the list recently asking about geting
  12. a single character in from the console without waiting on a charage return.
  13.   
  14.   This is how I do it.  The following code will go to sleep for about 100
  15. microseconds waiting on a character, then if no character was found it will
  16. return NIL.  This will only work if the console is in the raw mode.
  17.  
  18.   The reason I need to read characters in this way is that I am writing games
  19. for a bbs program that gets it's input from the stdout path, and I must
  20. always watch for the user droping the carrier.
  21.  
  22.   If anyone knows of a better way to do this please let me know.
  23.  
  24. Eric James
  25. ejames@venus.iucf.indiana.edu
  26.  
  27.  
  28. PROC get_the_char()
  29.   DEF returnval
  30.   returnval :=NIL
  31.                                    { wait for a char from stdout from about }
  32.                                    { 100 micro seconds and return TRUE if   }
  33.   IF WaitForChar(stdout,100)       { one is found  }
  34.      Read(stdout,{returnval},1)    { read the value to the location of }
  35.                                    { the variable returnval }
  36.      CLR.L D0                      { now to shift the value to the lsb of }
  37.      MOVE.B returnval,D0           { the variable to make it compatiable  }
  38.      MOVE.L D0,returnval           { with standard E variables }
  39.   ENDIF
  40. ENDPROC returnval